import request from '@/utils/request'
import {useExampleStore} from "@/stores/exampleStore.js";

// 查询学校端用户列表
export function listUsers(query) {
  return request({
    url: '/schoolmanage/users/list',
    method: 'get',
    params: query
  })
}

// 查询学校端用户详细
export function getUsers(schoolUserId) {
  return request({
    url: '/schoolmanage/users/' + schoolUserId,
    method: 'get'
  })
}

// 新增学校端用户
export function addUsers(data) {
  return request({
    url: '/schoolmanage/users',
    method: 'post',
    data: data
  })
}

// 修改学校端用户
export function updateUsers(data) {
  return request({
    url: '/schoolmanage/users',
    method: 'put',
    data: data
  })
}

// 删除学校端用户
export function delUsers(schoolUserId) {
  return request({
    url: '/schoolmanage/users/' + schoolUserId,
    method: 'delete'
  })
}

export function getSchoolId(query) {
  const exampleStore = useExampleStore()
  const schoolId = exampleStore.school; // 从 Pinia 获取 school_id
  const params = { ...query, schoolId: schoolId};
  return request({
    url: '/schoolmanage/users/list',
    method: 'get',
    params: params
  })
}
